package com.jtpay.sdk.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Date;

/**
 * Created by Joe on 2017/3/23 0023 11:42.
 * timer control model
 */

public class TimerControlInfo implements Parcelable {
    private Date startDate=null;
    private Date secondDate=null;
    private Date endDate=null;
    private int index=0;
    private int TimerCounts=30;
    private String token;
    private boolean isDown=true;

    public void DateInfoInit(){
        this.startDate=null;
        this.secondDate=null;
        this.endDate=null;
        this.isDown=false;
        this.TimerCounts=30;
        this.index=0;
        this.token="";
    }
    public void DateInfoClear(){
        this.startDate=null;
        this.secondDate=null;
        this.endDate=null;
    }
    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public boolean isDown() {
        return isDown;
    }

    public void setDown(boolean down) {
        isDown = down;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public int getTimerCounts() {
        return TimerCounts;
    }

    public void setTimerCounts(int timerCounts) {
        TimerCounts = timerCounts;
    }

    public Date getSecondDate() {
        return secondDate;
    }

    public void setSecondDate(Date secondDate) {
        this.secondDate = secondDate;
    }

    @Override
    public String toString() {
        return "TimerControlInfo{" +
                "startDate=" + startDate +
                ", secondDate=" + secondDate +
                ", endDate=" + endDate +
                ", index=" + index +
                ", TimerCounts=" + TimerCounts +
                ", token='" + token + '\'' +
                ", isDown=" + isDown +
                '}';
    }

    public TimerControlInfo() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.startDate != null ? this.startDate.getTime() : -1);
        dest.writeLong(this.secondDate != null ? this.secondDate.getTime() : -1);
        dest.writeLong(this.endDate != null ? this.endDate.getTime() : -1);
        dest.writeInt(this.index);
        dest.writeInt(this.TimerCounts);
        dest.writeString(this.token);
        dest.writeByte(this.isDown ? (byte) 1 : (byte) 0);
    }

    protected TimerControlInfo(Parcel in) {
        long tmpStartDate = in.readLong();
        this.startDate = tmpStartDate == -1 ? null : new Date(tmpStartDate);
        long tmpSecondDate = in.readLong();
        this.secondDate = tmpSecondDate == -1 ? null : new Date(tmpSecondDate);
        long tmpEndDate = in.readLong();
        this.endDate = tmpEndDate == -1 ? null : new Date(tmpEndDate);
        this.index = in.readInt();
        this.TimerCounts = in.readInt();
        this.token = in.readString();
        this.isDown = in.readByte() != 0;
    }

    public static final Creator<TimerControlInfo> CREATOR = new Creator<TimerControlInfo>() {
        @Override
        public TimerControlInfo createFromParcel(Parcel source) {
            return new TimerControlInfo(source);
        }

        @Override
        public TimerControlInfo[] newArray(int size) {
            return new TimerControlInfo[size];
        }
    };
}
